<template>
  <div class="leader-block">
    <div class="time">{{ currentTime }}</div>
    <div class="title">湖北省社保基金监管系统</div>
    <div class="content">
      <div class="flex-card">
        <div class="first">
          <div class="cityname"><img src="../assets/img/line.png" alt="">{{ this.selectData.name }}<img
              src="../assets/img/line.png" alt=""></div>
          <div class="states">
            <img src="../assets/img/icon.png" alt="">
            <div>核查警示</div>
            <div>期别xxx</div>
            <div>险种xxx</div>
          </div>
          <div class="num">
            涉及金额
            <div class="price">
              <span style="color:#FF9E02;">{{ this.selectData.value1 }}</span>万元
            </div>
          </div>
          <div class="num">
            涉及金额
            <div class="price">
              <span style="color:#FEFE00;">{{ this.selectData.value2 }}</span>万元
            </div>
          </div>
        </div>
        <div class="second" id="myEcharts1"></div>
      </div>
      <div class="mapbox">
        <div id="myMap"></div>
        <span class="arrow"><img src="../assets/img/arrow-left.png" alt=""></span>
        <span class="arrow2"><img src="../assets/img/arrow-right.png" alt=""></span>
        <div class="dangoustype">
          <div class="label">
            <img src="../assets/img/icon4.png" alt="">
            <div>险种名称1</div>
          </div>
          <div class="label">
            <img src="../assets/img/icon3.png" alt="">
            <div>险种名称2</div>
          </div>
          <div class="label">
            <img src="../assets/img/icon2.png" alt="">
            <div>险种名称3</div>
          </div>
          <div class="label">
            <img src="../assets/img/icon6.png" alt="">
            <div>险种名称4</div>
          </div>
          <div class="label">
            <img src="../assets/img/icon.png" alt="">
            <div>险种名称</div>
          </div>
        </div>
      </div>
      <div class="flex-card">
        <div class="first">
          <div class="cityname"><img src="../assets/img/line.png" alt="">
            {{ this.selectData.name }}<img src="../assets/img/line.png" alt="">
          </div>
          <div class="type-state" style="margin-bottom:30px;">
            <img src="../assets/img/icon2.png" alt="">
            <div class="name">重大</div>
            <div>要情编码：8288273</div>
          </div>
          <div class="type-state">
            <img src="../assets/img/icon3.png" alt="">
            <div class="name">险种名称</div>
            <div>涉及基金名称</div>
          </div>
          <div class="align-line">
            <div class="num">
              涉及金额
              <div class="price">
                <span style="color:#FF9E02;">{{ this.selectData.value3 }}</span>万元
              </div>
            </div>
            <div class="num">
              涉及金额
              <div class="price">
                <span style="color:#FEFE00;">{{ this.selectData.value4 }}</span>万元
              </div>
            </div>
          </div>
        </div>
        <div class="second" id="myEcharts2"></div>
      </div>
    </div>
    <div class="footer"></div>
  </div>
</template>
<script>
import hubei from './hubei.json'
import demoData from './demoData.json'
import { color } from 'echarts';
export default {
  name: "hubeiChartsData",
  components: {},
  props: {},
  data() {
    return {
      mapdata: demoData,
      selectData: {
        name: '湖北省',
        value1: '283.23',
        value2: '128.22',
        value3: '123.23',
        value4: '128.23'
      },
      fromName: '武汉',
      fromLatlng: [114.33, 30.82],
      geoCoordMap: [
        { name: '黄石', latlng: [115.01, 30.1] },
        { name: '十堰', latlng: [110.47, 32.65] },
        { name: '宜昌', latlng: [111.14, 30.92] },
        { name: '神农架林区', latlng: [110.5, 31.77] },
        { name: '恩施土家族苗族自治州', latlng: [109.5, 30.4] },
        { name: '孝感', latlng: [113.88, 31.3] },
        { name: '黄冈', latlng: [115.35, 30.9] },
        { name: '随州', latlng: [113.42, 32.01] },
        { name: '襄阳', latlng: [111.94, 32.1] },
        { name: '荆门', latlng: [112.6, 31.26] },
        { name: '潜江', latlng: [112.75, 30.46] },
        { name: '荆州', latlng: [112.24, 29.99] },
        { name: '仙桃', latlng: [113.65, 30.3] },
        { name: '咸宁', latlng: [114.19, 29.8] },
        { name: '鄂州', latlng: [114.75, 30.48] },
        { name: '天门', latlng: [113.24, 30.53] }
      ],
      // 横纵比
      aspectScale: 1,
      currentTime: this.getDateTime()
    };
  },
  computed: {},
  watch: {},
  mounted() {
    this.hubeiMap()
    this.echartsData1()
    this.echartsData2()
    var that = this
    this.timer = setInterval(function () {
      that.currentTime = that.getDateTime()
    }, 1000)
  },
  methods: {
    getDateTime() {
      let year = new Date().getFullYear();
      let month = new Date().getMonth() + 1 < 10 ? "0" + (new Date().getMonth() + 1) : new Date().getMonth() + 1;
      let date = new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate();
      let hh = new Date().getHours() < 10 ? "0" + new Date().getHours() : new Date().getHours();
      let mm = new Date().getMinutes() < 10 ? "0" + new Date().getMinutes() : new Date().getMinutes();
      let ss = new Date().getSeconds() < 10 ? "0" + new Date().getSeconds() : new Date().getSeconds();
      return year + "-" + month + "-" + date + " " + hh + ":" + mm + ':' + ss
    },
    convertData(data) {
      var res = []
      for (var i = 0; i < data.length; i++) {
        var geoCoord = this.geoCoordMap[data[i].name]
        if (geoCoord) {
          res.push({
            name: data[i].name,
            value: geoCoord.concat(data[i].value)
          })
        }
      }
      return res
    },
    linesData() {
      return this.geoCoordMap.map(row => {
        return {
          coords: [
            this.fromLatlng,
            row.latlng
          ],
          fromName: this.fromName,
          toName: row.name
        }
      })
    },
    effectData() {
      return this.geoCoordMap.map(row => {
        return {
          value: row.latlng,
          name: row.name
        }
      })
    },
    hubeiMap() {
      // 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('myMap'))
      this.$echarts.registerMap('hubei', hubei)
      var that = this
      var option = {
        layoutCenter: ['50%', '45%'], //位置
        layoutSize: '98%', //大小
        tooltip: {
          show: true,
          triggerOn: "click",   //mousemove、click
          padding: [4, 8],
          borderWidth: 1,
          borderColor: '#12CDFF',
          backgroundColor: 'rgba(0,0,0,0.6)',
          textStyle: {
            color: '#000000',
            fontSize: 13
          },
          formatter: function (e) {
            that.selectData = e.data
            console.log(e);
            var res = '<div style="background:rgba(0,0,0,0.65);padding:0 20px 20px;box-sizing:border-box;color:#fff;width: 300px;border-radius: 4px;height: 180px;position:absolute;z-index:9;">' +
              '<div style="height:50px;font-weight:bold;border-bottom: 1px solid rgba(255,255,255,0.2);display:flex;align-items: center;">' +
              '  <span style="display:inline-block;background:#3888FC;width:10px;height:10px;transform: rotate(45deg);"></span>' +
              '  <span  style="display:inline-block;background:#4EE6AF;width:10px;height:10px;transform: rotate(45deg);margin-right: 10px;"></span>' + e.name +
              '</div>' +
              '<div style="font-size:14px;">涉及金额</div>' +
              '<div style="display:flex;justify-content: space-between;line-height:40px;">' +
              '  <div style="font-size:12px;"><span style="color:#00FFFF;font-size:16px;margin-right:10px;">' + e.data.value1 + '</span>万元</div>' +
              '  <div style="font-size:12px;">同比：<span style="color:#FFB700;font-size:16px;margin-right:10px;">↑4.3%</span></div>' +
              '</div>' +
              '<div style="font-size:14px;">追回金额</div>' +
              '<div style="display:flex;justify-content: space-between;line-height:40px;">' +
              ' <div style="font-size:12px;"><span style="color:#00FFFF;font-size:16px;margin-right:10px;">' + e.data.value2 + '</span>万元</div>' +
              ' <div style="font-size:12px;">同比：<span style="color:#FFB700;font-size:16px;margin-right:10px;">↑4.3%</span></div>' +
              '</div></div>';
            return res;
          }
        },
        geo: [
          {
            map: "hubei",
            z: 3,
            zoom: 1.2,
            aspectScale: this.aspectScale,
            roam: false,
            layoutSize: "100%", //保持地图宽高比
            label: {
              normal: {
                show: true, //显示省份标签
                formatter: function (params) {
                  if (params.name == '武汉市') {
                    // 放大武汉的字体
                    return `{a|${params.name}}`
                  } else {
                    return `{b|${params.name}}`
                  }
                },
                rich: {
                  a: {
                    color: 'white',
                    fontSize: 18,
                  },
                  b: {
                    color: 'white',
                    fontSize: 14,
                  }
                },
              },
              emphasis: {
                //对应的鼠标悬浮效果
                show: true,
                label: {
                  textStyle: { color: '#fff' }
                }
              }
            },
            itemStyle: {
              borderColor: '#c8feff',
              borderWidth: 0.5,
              shadowBlur: 3,
              shadowColor: '#66edff',
              areaColor: '#0862db'
            },
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                borderWidth: 1,
                areaColor: '#2da9ff',
              },
              label: {
                show: false,
                color: '#ffffff',
              }
            },
            select: {
              itemStyle: {
                shadowBlur: 10,
                borderWidth: 1,
                areaColor: '#2da9ff',
              },
              label: {
                color: '#ffffff',
              }
            }
          },
          {
            map: "hubei",
            z: 2,
            zoom: 1.2,
            aspectScale: this.aspectScale,
            roam: false,
            silent: true,
            layoutSize: "100%", //保持地图宽高比
            itemStyle: {
              borderColor: '#d8feff',
              borderWidth: 3,
              shadowBlur: 10,
              shadowColor: '#070D99',
              areaColor: '#070D99',
              shadowOffsetX: 0,
              shadowOffsetY: 18
            },
          },
          {
            map: "hubei",
            z: 1,
            zoom: 1.2,
            aspectScale: this.aspectScale,
            roam: false,
            silent: true,
            layoutSize: "100%", //保持地图宽高比
            itemStyle: {
              borderColor: '#d8feff',
              borderWidth: 3,
              shadowBlur: 10,
              shadowColor: '#070D99',
              areaColor: '#070D99',
              shadowOffsetX: 0,
              shadowOffsetY: 28
            },
          }
        ],
        series: [
          {
            type: "map",
            geoIndex: 0,
            data: this.mapdata
          },
          {
            type: 'lines',
            zlevel: 5,
            effect: {
              show: true,
              period: 5, //箭头指向速度，值越小速度越快
              trailLength: 0, //特效尾迹长度[0,1]值越大，尾迹越长重
              symbol: 'circle', //ECharts 提供的标记类型包括 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
              symbolSize: 8, //图标大小
            },
            lineStyle: {
              color: "#00eaff",
              width: 2, //尾迹线条宽度
              opacity: 1, //尾迹线条透明度
              curveness: 0.3, //尾迹线条曲直度
            },
            data: this.linesData(),
            markPoint: {
              symbol: 'circle', //ECharts 提供的标记类型包括 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
              symbolSize: 8, //图标大小
            }
          },
          {
            type: 'effectScatter',
            coordinateSystem: 'geo',
            zlevel: 6,
            rippleEffect: {
              //涟漪特效
              period: 4, //动画时间，值越小速度越快
              brushType: 'stroke', //波纹绘制方式 stroke, fill
              scale: 4 //波纹圆环最大限制，值越大波纹越大
            },
            label: {
              show: false,
              position: 'right', //显示位置
              offset: [5, 0], //偏移设置
              formatter: '{b}', //圆环显示文字
            },
            symbol: 'circle',
            symbolSize: function (val) {
              return 18;//标识大小
            },
            itemStyle: {
              show: false,
              color: '#FFFF00',
            },
            data: [{ value: this.fromLatlng, name: this.fromName }]
          },
          {
            type: 'scatter',
            coordinateSystem: 'geo',
            zlevel: 6,
            rippleEffect: {
              //涟漪特效
              period: 4, //动画时间，值越小速度越快
              brushType: 'stroke', //波纹绘制方式 stroke, fill
              scale: 4 //波纹圆环最大限制，值越大波纹越大
            },
            symbol: 'circle',
            symbolSize: function (val) {
              return 10; //标识大小
            },
            itemStyle: {
              show: false,
              color: '#befaff',
            },
            data: this.effectData()
          }
        ]
      }
      myChart.setOption(option)
    },
    echartsData1() {
      var myChart = this.$echarts.init(document.getElementById('myEcharts1'))
      var option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: '#999'
            }
          }
        },
        grid: {
          top: '30%',
          left: "8%",
          right: "8%",
          bottom: '10%',
        },
        legend: {
          top: "0",
          textStyle: {
            color: '#fff',
            fontSize: 12
          },
          data: ['检查数量', '检查率', '资金整改率']
        },
        xAxis: [
          {
            type: 'category',
            data: ['2024.04', '2024.05', '2024.06', '2024.07', '2024.08'],
            axisLabel: {
              color: '#B1D1E9'
            },
            axisPointer: {
              type: 'shadow'
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            name: '个',
            nameTextStyle: {
              color: '#B1D1E9'
            },
            axisLabel: {
              color: '#B1D1E9'
            },
            splitLine: {
              "show": false
            }
          },
          {
            type: 'value',
            name: '%',
            nameTextStyle: {
              color: '#B1D1E9'
            },
            min: 0,
            max: 100,
            axisLabel: {
              color: '#B1D1E9'
            },
            splitLine: {
              "show": false
            }
          }
        ],
        series: [
          {
            name: '检查数量',
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' 个';
              }
            },
            data: [
              400, 389, 200, 760, 565
            ],
            // 设置渐变色
            itemStyle: {
              color: new this.$echarts.graphic.LinearGradient(
                0, 0, 0, 1, // 渐变方向从上到下
                [
                  { offset: 0, color: '#1274E7' },   // 上部颜色
                  { offset: 1, color: '#2E3ED3' }    // 下部颜色
                ]
              )
            }
          },
          {
            name: '检查率',
            type: 'line',
            symbol: 'circle',
            smooth: true, // 启用平滑曲线
            tooltip: {
              valueFormatter: function (value) {
                return value + ' %';
              }
            },
            data: [
              90, 59, 90, 26.4, 28.7
            ],
            // 设置折线颜色
            itemStyle: {
              normal: {
                color: '#67C5FD', // 点的颜色
                lineStyle: {
                  color: '#67C5FD' // 线的颜色
                }
              }
            }
          },
          {
            name: '资金整改率',
            type: 'line',
            symbol: 'circle',
            smooth: true, // 启用平滑曲线
            yAxisIndex: 1,
            tooltip: {
              valueFormatter: function (value) {
                return value + ' %';
              }
            },
            data: [20, 22, 33, 45, 63],
            // 设置折线颜色
            itemStyle: {
              normal: {
                color: '#60F0CE', // 点的颜色
                lineStyle: {
                  color: '#60F0CE' // 线的颜色
                }
              }
            }
          }
        ]
      }
      myChart.setOption(option);
    },
    echartsData2() {
      var myChart = this.$echarts.init(document.getElementById('myEcharts2'))
      var option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: '#999'
            }
          }
        },
        grid: {
          top: '30%',
          left: "8%",
          right: "8%",
          bottom: '10%',
        },
        legend: {
          textStyle: {
            color: '#fff',
            fontSize: 12
          },
          data: ['涉及金额', '要情总数', '重大要情数']
        },
        xAxis: [
          {
            type: 'category',
            data: ['2021', '2022', '2023', '2024'],
            axisLabel: {
              color: '#B1D1E9'
            },
            axisPointer: {
              type: 'shadow'
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            name: '万元',
            nameTextStyle: {
              color: '#B1D1E9'
            },
            axisLabel: {
              color: '#B1D1E9'
            },
            splitLine: {
              "show": false
            }
          },
          {
            type: 'value',
            name: '个',
            nameTextStyle: {
              color: '#B1D1E9'
            },
            axisLabel: {
              color: '#B1D1E9'
            },
            splitLine: {
              "show": false
            }
          }
        ],
        series: [
          {
            name: '涉及金额',
            type: 'bar',
            tooltip: {
              valueFormatter: function (value) {
                return value + ' 万元';
              }
            },
            data: [
              400, 389, 200, 760
            ],
            // 设置渐变色
            itemStyle: {
              color: new this.$echarts.graphic.LinearGradient(
                0, 0, 0, 1, // 渐变方向从上到下
                [
                  { offset: 0, color: '#1274E7' },   // 上部颜色
                  { offset: 1, color: '#2E3ED3' }    // 下部颜色
                ]
              )
            }
          },
          {
            name: '要情总数',
            type: 'line',
            symbol: 'circle',
            smooth: true, // 启用平滑曲线
            tooltip: {
              valueFormatter: function (value) {
                return value + ' 个';
              }
            },
            data: [
              20, 59, 90, 26
            ],
            // 设置折线颜色
            itemStyle: {
              normal: {
                color: '#67C5FD', // 点的颜色
                lineStyle: {
                  color: '#67C5FD' // 线的颜色
                }
              }
            }
          },
          {
            name: '重大要情数',
            type: 'line',
            // 标记符号
            symbol: 'circle',
            smooth: true, // 启用平滑曲线
            yAxisIndex: 1,
            tooltip: {
              valueFormatter: function (value) {
                return value + ' 个';
              }
            },
            data: [10, 22, 33, 12],
            // 设置折线颜色
            itemStyle: {
              normal: {
                color: '#60F0CE', // 点的颜色
                lineStyle: {
                  color: '#60F0CE' // 线的颜色
                }
              }
            }
          }
        ]
      }
      myChart.setOption(option);
    }
  }
}
</script>

<style>
@font-face {
  font-family: 'digifaw';
  src: url('digifaw.ttf');
  font-weight: normal;
  font-style: normal;
}
</style>
<style scoped>
.leader-block {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  background: #050822 url(../assets/img/background.png) no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
}

.title {
  text-align: center;
  color: #fff;
  font-size: 36px;
  font-weight: bold;
  background: url(../assets/img/head.png) no-repeat;
  background-size: 100% 100%;
  width: 100%;
  position: absolute;
  top: 0;
  z-index: 2;
  height: 100px;
  left: 0;
  line-height: 75px;
  letter-spacing: 10px;
}

.content {
  position: absolute;
  top: 100px;
  bottom: 60px;
  left: 20px;
  right: 20px;
  display: flex;
}

.footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: url(../assets/img/footer.png) no-repeat;
  background-size: 100%;
}

.flex-card {
  flex: 1;
  position: relative;
}

.first {
  height: 60%;
  background: url(../assets/img/card-one.png) no-repeat;
  background-size: 100% 100%;
  color: #fff;
  padding: 30px;
  box-sizing: border-box;
}

.second {
  position: absolute;
  height: 38%;
  bottom: 0;
  left: 0;
  right: 0;
  background: url(../assets/img/card-two.png) no-repeat;
  background-size: 100% 100%;
  color: #fff;
  padding: 30px;
  box-sizing: border-box
}

.cityname {
  font-size: 30px;
  font-weight: bold;
  color: #00ffff;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 60px;
}

.states {
  display: flex;
  justify-content: center;
  align-items: center;
}

.states img {
  width: 80px;
  height: auto;
}

.states div {
  flex: 1;
  background: url(../assets/img/titbac.png) no-repeat;
  background-size: 100% 100%;
  margin: 0 10px;
  padding: 10px 20px;
}

.num {
  text-align: center;
  padding: 30px 0 0;
}

.num .price span {
  font-size: 40px;
  font-family: 'digifaw';
  margin-right: 10px;
}

.cityname img {
  width: 50px;
  height: 10px;
  margin: 0 20px;
}

.type-state {
  position: relative;
  margin-left: 30px;
  background: linear-gradient(to right, #183875, rgba(24, 44, 78, 0));
  padding-left: 50px;
  height: 60px;
  box-sizing: border-box;
  font-size: 14px;
}

.type-state img {
  width: 80px;
  height: auto;
  position: absolute;
  left: -40px;
  top: 0;
}

.type-state .name {
  font-size: 18px;
  line-height: 30px;
  font-weight: bold;
}

.align-line {
  display: flex;
}

.align-line .num {
  flex: 1;
}

.mapbox {
  width: 50%;
  height: 100%;
  position: relative;
}

.mapbox .arrow {
  position: absolute;
  top: 50%;
  width: 50px;
  height: 50px;
  left: 0;
  margin-top: -40px;
}

.mapbox .arrow2 {
  right: 0;
  position: absolute;
  top: 50%;
  width: 50px;
  height: 50px;
  margin-top: -40px;
}

#myMap {
  width: 100%;
  height: 90%;
}

.dangoustype {
  display: flex;
  position: absolute;
  bottom: 0;
  width: 100%;
  justify-content: space-between;
  padding: 0 40px;
  box-sizing: border-box;
}

.dangoustype .label {
  text-align: center;
  color: #fff;
  background: rgba(14, 9, 77, 0.6);
  border: 0.5px solid #66FFFF;
  border-radius: 4px;
  height: 100px;
  overflow: hidden;
  width: 100px;
  font-size: 14px;
}

.dangoustype img {
  width: 80px;
  height: auto;
  margin-top: 10px;
}

.label div {
  position: relative;
  top: -10px;
}

.time {
  position: absolute;
  top: 0;
  left: 20px;
  color: #fff;
  width: 200px;
  z-index: 9;
  line-height: 60px;
  font-size: 14px;
}
</style>
